package com.data.codegenerate.generate.util;

import java.io.IOException;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import org.apache.commons.lang.RandomStringUtils;

public class NonceUtils {
    private static final SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    private static final String[] b = {"0", "00", "0000", "00000000"};
    private static Date c;
    private static int d = 0;

    public static String a(int i) {
        return RandomStringUtils.randomAlphanumeric(i);
    }

    public static int a() {
        return new SecureRandom().nextInt();
    }

    public static String b() {
        return Integer.toHexString(a());
    }

    public static long c() {
        return new SecureRandom().nextLong();
    }

    public static String d() {
        return Long.toHexString(c());
    }

    public static String e() {
        return UUID.randomUUID().toString();
    }

    public static String f() {
        return a.format(new Date());
    }

    public static long g() {
        return System.currentTimeMillis();
    }

    public static String h() {
        return Long.toHexString(g());
    }

    public static synchronized String i() {
        String hexString;
        synchronized (NonceUtils.class) {
            Date date = new Date();
            if (date.equals(c)) {
                d++;
            } else {
                c = date;
                d = 0;
            }
            hexString = Integer.toHexString(d);
        }
        return hexString;
    }

    public static String a(String str, int i) {
        int length = i - str.length();
        StringBuilder sb = new StringBuilder();
        while (length >= 8) {
            sb.append(b[3]);
            length -= 8;
        }
        for (int i2 = 2; i2 >= 0; i2--) {
            if (((1 << i2) & length) != 0) {
                sb.append(b[i2]);
            }
        }
        sb.append(str);
        return sb.toString();
    }

    public static void main(String[] args) throws IOException {
        System.out.println(c() + g());
    }
}
